Environment Variables
Catalyst can be configured through a config/config.json
file in the root of your project directory.
You can define your keys to access them inside the project.
Loading environment variables on the server
To load environment variables on the server, you need to specify them in the config/config.json
file as a JSON object. These variables will be accessible through process.env[variable_name]
.
Here are the default values for some environment variables:
key | default | description |
---|---|---|
NODE_SERVER_HOSTNAME | "localhost" | Change the server hostname while running your application |
NODE_SERVER_PORT | 3005 | Change the server port while running your application |
WEBPACK_DEV_SERVER_HOSTNAME | "localhost" | It defines application client hostname where your client dev server will be running |
WEBPACK_DEV_SERVER_PORT | 3006 | It defines application client port where your client dev server will be running |
BUILD_OUTPUT_PATH | build | Use this to describe your build folder name or path |
PUBLIC_STATIC_ASSET_PATH | "/assets/" | This key is used to add your path from where you are serving your assets, by default your assets get served from the server. You can change this and add your cdn path to serve assets from there |
PUBLIC_STATIC_ASSET_URL | "http://localhost:3006" | This key is used to change your hostname from where you want your assets to be served. |
NODE_ENV | development | Define your node environment |
API_URL | "" | You can use this key to provide API url for your application. We are using this key inside fetch instance which we have provided for api calling |
ANALYZE_BUNDLE | false | Enable webpack analyze for bundle information |
CLIENT_ENV_KEYS | [] | Keys which are written inside config.json will not be available to client code. To access them at client, you need to specify them inside this array |
ENABLE_DEBUG_LOGS | false | Disable file logs by passing false to this key in config.json |
ENABLE_CONSOLE_LOGGING | true | Disable all types of logs in production or development by passing a boolean |
Loading environment variables on the client
Out of the complete contents of config/config.json
,
keys listed in CLIENT_ENV_KEYS
are filtered and made available for the client side code.
Any key that is listed in
CLIENT_ENV_KEYS
will be exposed on the client and can become a security issue. Be careful while adding keys